﻿Public Class MainCategory
    Dim DACatRoom As New DSFloorManagemantTableAdapters.ROOM_CATEGORYTableAdapter
    Private Sub ToolStripButton1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripButton1.Click
        Dim FCategoryRoom As New FormCategoryRoom
        If FCategoryRoom.ShowDialog = Windows.Forms.DialogResult.OK Then
            RefreshData()
        End If
    End Sub

    Private Sub ToolStripButton4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripButton4.Click
        RefreshData()
    End Sub

    Private Sub RefreshData()
        GridEX1.DataSource = DACatRoom.GetData
    End Sub

    Private Sub ToolStripButton2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripButton2.Click
        If GridEX1.SelectedItems.Count = 0 Then Exit Sub
        Dim FCategoryRoom As New FormCategoryRoom
        FCategoryRoom.lblSaveOption.Text = GridEX1.GetRow.Cells("CATEGORY_ID").Value
        FCategoryRoom.TxtRoomCategory.Text = GridEX1.GetRow.Cells("GATEGORY_NAME").Value
        FCategoryRoom.TxtRoomCategoryDes.Text = GridEX1.GetRow.Cells("GATEGORY_DESCRIPTION").Value
        If FCategoryRoom.ShowDialog = Windows.Forms.DialogResult.OK Then
            RefreshData()
        End If
    End Sub

    Private Sub ToolStripButton3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripButton3.Click
        If GridEX1.SelectedItems.Count = 0 Then
            Exit Sub
        Else
            If MessageBox.Show("Do you want delete this category?", "Room", MessageBoxButtons.YesNo, MessageBoxIcon.Question) = Windows.Forms.DialogResult.Yes Then
                If DACatRoom.IS_DELETE(True, GridEX1.GetRow.Cells("CATEGORY_ID").Value) = 1 Then
                    RefreshData()
                End If
            End If
        End If
    End Sub

    Private Sub MainCategory_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        RefreshData()
    End Sub
End Class